import src
import numpy as np
import multiprocessing as multi


def main(path=None,cpus=multi.cpu_count()):
    if path is None:
        path = src.redu.gui_getdir(title = 'Please Select Fits Directory')
	if not path:
		raise ValueError( 'Must specify directory where files are.' )
	if not path.endswith( '/' ):
		path += '/'
    #unravels fits and sorts into photmetry/spectra
	src.divide.check_ccd_type(path)
    #gets loop redy for cal 
	paths = src.divide.get_dir(path)
	for path in paths:
        #make new path
		print path
		src.divide.div(path)
		src.divide.products(path)
        #set wcs for lights
        src.astmry.main(path)
        raise
        #calibrate
        print '****************Bias**************'
        rb.SubtractBias(path=path)
        print '****************Dark**************'
        rb.RemoveDarks(path)
        print '****************Flat**************'
        rb.RemoveFlat(path=path)
        print '****************Done**************'



"test"
class reduce_daemon(object):
    '''Reduction daemon to do auto reduction. Checks a directory for new files
and will sort then reduce them automatically. Once reduction is complete,
will do photometry, and add postage stamps to a database'''

    def __init__(self,watch_path,cal_path,database_path):
        #initalize
        self.watch_path = watch_path
        self.cal_path = cal_path
        self.database_path = database_path



if __name__ == '__main__':

    '''comand lin running'''
    main()
